/**  
* @author renbangjie renbangjie@126.com  
* @date 2015-6-23 下午6:07:25
* @version V1.0  
* <b>Copyright (c)</b> 2014医信金融信息服务（上海）有限公司-版权所有<br/>
*/
package com.yjd.comm.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 用户相关枚举类型
 * @author renbangjie renbangjie@126.com
 * @date 2015-6-23 下午6:07:25
 */
public class UserEnums {

	/**
	 * 用户类型
	* @author renbangjie renbangjie@126.com
	* @date 2015-6-23 下午6:07:58
	 */
	public enum UserType {
		
		NORMAL(0, "普通用户"),
		INVEST(1,"投资人"),
		VIP(2, "vip投资用户"),
		BORROWER(4, "借款用户"),
		CARD(8, "理财卡用户"),
		DZ_USER(16,"东庄用户");
		
		private int code;
		private String lable;
		
		private UserType(int code, String lable) {
			this.code = code;
			this.lable = lable;
		}
		
		
		public static UserType get(int code){
			for (UserType t : UserType.values()) {
				if(t.getCode() == code){
					return t;
				}
			}
			return null;
		}

		/**
		 * 根据用户类型判断是否是东庄用户
		 * @param userType
		 * @return
		 */
		public static boolean isDz(Integer userType){
			return userType!=null && (userType & UserType.DZ_USER.getCode()) == UserType.DZ_USER.getCode();
		}
		

		public int getCode() {
			return code;
		}

		public void setCode(int code) {
			this.code = code;
		}

		public String getLable() {
			return lable;
		}

		public void setLable(String lable) {
			this.lable = lable;
		}
		
	}
	
	public enum Status{
		normal(0,"正常"),notregist(1,"未注册用户"),nopassword(2,"未设置密码");
		private Status(int code,String lable){
			this.code=code;
			this.lable=lable;
		}
		private int code;
		private String lable;
		public int getCode() {
			return code;
		}
		public void setCode(int code) {
			this.code = code;
		}
		public String getLable() {
			return lable;
		}
		public void setLable(String lable) {
			this.lable = lable;
		}
		
	}
	
	/**
	 * 用户分类
	 */
	public enum UserMold {
		PERSONAL(1,"个人用户"),
		ENTERPRISE(2, "企业法人用户");
		
		private int code;
		private String lable;
		
		private UserMold(int code, String lable) {
			this.code = code;
			this.lable = lable;
		}
		
		
		public static UserMold get(int code){
			for (UserMold t : UserMold.values()) {
				if(t.getCode() == code){
					return t;
				}
			}
			return null;
		}
		

		public int getCode() {
			return code;
		}

		public void setCode(int code) {
			this.code = code;
		}

		public String getLable() {
			return lable;
		}

		public void setLable(String lable) {
			this.lable = lable;
		}
		
	}
	/**
	 * 注册渠道
	* @author renbangjie renbangjie@126.com
	* @date 2015-6-23 下午6:09:24
	 */
	public enum Channel {
		NONE(0, "未知"),//未知
		PC(1, "pc"),//PC
		ANDROID(2, "android"),//安卓
		IOS(3, "ios"),//苹果
		WEIXIN(4, "weixin"),//微信
		WAP(5, "wap"),//微站
		BACK(6, "活动中心发放"),//活动中心发放
		BACKMANAGER(7, "后台管理");//后台管理
		
		private int code;
		private String lable;
		
		private Channel(int code, String lable) {
			this.code = code;
			this.lable = lable;
		}

		public int getCode() {
			return code;
		}

		public void setCode(int code) {
			this.code = code;
		}

		public String getLable() {
			return lable;
		}

		public void setLable(String lable) {
			this.lable = lable;
		}
		
		public static Channel getChannel(String lable){
			Channel[] channels = Channel.values();
			for(Channel c : channels){
				if(StringUtils.isNotBlank(lable)&&lable.equalsIgnoreCase(c.getLable())){
					return c;
				}
			}
			return Channel.PC;
		}
		
		public static Channel getChannel(int code){
			Channel[] channels = Channel.values();
			for(Channel c : channels){
				if(c.getCode()==code){
					return c;
				}
			}
			return Channel.PC;
		}
	}
	
}
